<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<title></title>
		<style type="text/css">
			#box{
				width: 200px;
				height: 200px;
				background: red;
			}
		</style>
		<script type="text/javascript">
			window.onload = function(){
				var box = document.getElementById("box");
				var btn = document.getElementById("btn");
				btn.onclick = function(){
					//只能获取行内样式
//					var res = box.style.width;
//					alert(res);

					if(document.all){
						//ie
						var res = box.currentStyle.width;
					}else{
						//w3c
						var res = getComputedStyle(box,null).width;
					}
					alert(res);
				}
			}
		</script>
	</head>
	<body>
		<button id="btn">点我呀</button>
		<div id="box"></div>
	</body>
</html>
